package com.orhon.smartcampus.modules.course.entity;

import java.util.Date;

import javax.persistence.*;

import com.orhon.smartcampus.modules.base.entity.Dictionary;
import com.orhon.smartcampus.modules.base.entity.Schools;
import com.orhon.smartcampus.modules.base.entity.Subjects;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "course_courses", schema = "smartcloud", catalog = "")
public class Courses {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "course_slug", nullable = false, length = 191)
    private String courseSlug;

    @Column(name = "course_code", nullable = true)
    private Integer courseCode;

    @Column(name = "type", nullable = false)
    private String type;
    @Column(name = "created_at", nullable = true)
    private Date createdAt;
    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;
    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;
    @Column(name = "course_name", nullable = true)
    private String courseName;
    /**
     * 课程关联学校
     */
    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "school_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Schools schoolId;
    /**
     * 课程关联学科
     */
    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "subject_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Subjects subjectId;
    /**
     * 课程分类关联字典表
     */
    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "course_kind_dict", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Dictionary courseKindDict;
    /**
     * 课程级别关联字典表
     */
    @ManyToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "level_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Dictionary level;

}
